#include <stdio.h>
#include <math.h>

int primo(int m) {
    int i, max;
    if (m==1) return 0;
    if (m==2) return 1;
    max = sqrt(m);
    for (i=2;i<max;i++) {
        if (m%i == 0)
            return 0;
    }
    return ! (m%i == 0);
}

int main() {
    int n, i;
    int ant[4];
    ant[0] = ant[1] = ant[2] = -99;
    scanf("%d", &n);
    for (i=1;i<=n;i+=2) {
        if (primo(i)) {
            if (i-ant[0]==8 && i-ant[1]==6 && i-ant[2]==2)
                printf("%d %d %d %d\n",ant[0],ant[1],ant[2],i);
            ant[0] = ant[1];
            ant[1] = ant[2];
            ant[2] = i;
        }
    }
    return 0;
}
